package com.example.pattern.singleton;

//自认为史上最牛单例模式实现
public class LazyInnerClassCheckSingleton {

    private LazyInnerClassCheckSingleton() {
        //构造方法中做一些限制，一旦出现多次重复创建，则直接抛出异常
        if (LazyHolder.LAZY != null) {
            throw new RuntimeException("不允许创建多个实例！！");
        }
    }

    public static final LazyInnerClassCheckSingleton getInstance() {
        return LazyHolder.LAZY;
    }

    private static class LazyHolder {
        private static final LazyInnerClassCheckSingleton LAZY = new LazyInnerClassCheckSingleton();
    }

}
